const uuid = require('node-uuid');
/* 处理对象，过滤掉对象的空的属性和空串 */
function forMatObject(Obj) {
    if (typeof Obj === 'undefined') return null;
    for (const key in Obj) {
        const current = Obj[key];
        const type = Object.prototype.toString.call(current).split(' ')[1].slice(0, -1);
        switch (type) {
            case 'String':
                if (current.trim() == '') {
                    delete Obj[key];
                    continue;
                }
                Obj[key] = current.trim();
                break;
            case 'Object':
                if (JSON.stringify(current) == '{}') {
                    delete Obj[key];
                } else {
                    forMatObject(current);
                }
                break;
            case 'Number':
                break;
            case 'Boolean':
                break;
            default:
                if (current == null) {
                    delete Obj[key];
                    continue;
                }
        }
    }
    return Obj;
}
//获取一个唯一标识
function getUuid() {
    return uuid.v1();
}
module.exports = {
    forMatObject,
    getUuid
};